
using System;
using System.IO;
using System.Collections.Generic;
using System.Collections;

namespace Paret
{
	
	public class Papers
	{
		enum PapersExt {
			jpg,
			png,
		}
			
		string path;
		List<string> papers;
		Dictionary<PapersExt,string>  ext;
		int count;
		
		public Papers(string path)
		{
			this.path = path;
			ext = new Dictionary<PapersExt, string>();
			ext.Add(PapersExt.jpg,"jpg");
			ext.Add(PapersExt.png,"png");
			papers = new List<string>();
			count = 0;
		
		}
		
		public List<string> getPapers(){
			processPapers();
			return papers;
		}
		
		private void processPapers(){
			
			foreach (string paper in Directory.GetFiles(this.path))
			{
				foreach (PapersExt paperext in ext.Keys){
					if (paper.EndsWith(ext[paperext]))
						papers.Add(paper);
				}
			}
			papers.Sort();
		}
		
		public string getNextPaper()
		{
			if (count > papers.Count )
				count = 0;
			return papers[count++];
		}
				
	}
}
